package cn.iocoder.yudao.module.promotion.groupon.controller.app;

import cn.iocoder.yudao.framework.business.basic.controller.SimpleDetailController;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.promotion.groupon.pojo.vo.AppGrouponProductRespVO;
import cn.iocoder.yudao.module.promotion.groupon.service.app.AppGrouponProductService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.annotation.security.PermitAll;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "用户 App - 团购产品")
@RestController
@RequestMapping("/promotion/groupon-product")
@Validated
public class AppGrouponProductController implements SimpleDetailController<AppGrouponProductRespVO>  {

    @Resource
    private AppGrouponProductService appGrouponProductService;

    @PermitAll
    @Override
    public CommonResult<AppGrouponProductRespVO> getDetail(Long id) {
        AppGrouponProductRespVO data = appGrouponProductService.getDetail(id);
        return success(data);
    }

    @PermitAll
    @Operation(summary = "列表")
    @GetMapping("/list")
    public CommonResult<List<AppGrouponProductRespVO>> getList(@RequestParam("packageId") Long packageId) {
        return success(appGrouponProductService.getListByPackageId(packageId));
    }

}
